Use serde type system for handlebars
authorNing Sun <sunng@about.me>
Fri, 3 Mar 2017 09:25:06 +0000 (17:25 +0800)
committerNing Sun <sunng@about.me>
Fri, 3 Mar 2017 09:25:06 +0000 (17:25 +0800)
This will help cargo to drop rustc_serialize as dependency

Cargo.lock
Cargo.toml
src/cargo/util/template.rs

index 89782fa18d3656eb72bbb9245ac473d250721097..40cc4e6d864b0b6c6d6b4635af27da4359a68449 100644 (file)
@@ -272,7 +272,7 @@ dependencies = [
  "pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "quick-error 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_json 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
index 1bc2acda0eb5dce38cb4e8d15219e269c2e819c9..e158252a5b6cd434842fac4f3e915ddf7245bace 100644 (file)
@@ -28,7 +28,7 @@ fs2 = "0.4"
 git2 = "0.6"
 git2-curl = "0.7"
 glob = "0.2"
-handlebars = "0.25"
+handlebars = { version = "0.25", features = ["serde_type", "partial4"], default-features = false }
 libc = "0.2"
 libgit2-sys = "0.6"
 log = "0.3"
index 4ae1b93899196be5b4f87f0c6d45d65f7ecd0ddc..a4076589c0389b1778573c769966d325b36aedb9 100644 (file)
@@ -18,7 +18,7 @@ pub fn toml_escape_helper(h: &Helper,
                           _: &Handlebars,
                           rc: &mut RenderContext) -> Result<(), RenderError> {
     if let Some(param) = h.param(0) {
-        let txt = param.value().as_string().unwrap_or("").to_owned();
+        let txt = param.value().as_str().unwrap_or("").to_owned();
         let rendered = format!("{}", toml::Value::String(txt));
         try!(rc.writer.write_all(rendered.into_bytes().as_ref()));
     }
@@ -30,7 +30,7 @@ pub fn html_escape_helper(h: &Helper,
                           _: &Handlebars,
                           rc: &mut RenderContext) -> Result<(), RenderError> {
     if let Some(param) = h.param(0) {
-        let rendered = html_escape(param.value().as_string().unwrap_or(""));
+        let rendered = html_escape(param.value().as_str().unwrap_or(""));
         try!(rc.writer.write_all(rendered.into_bytes().as_ref()));
     }
     Ok(())